import 'babel-polyfill'
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import './styles/element-variables.scss'
// import { ElSelectV2 } from 'element-plus'
// import 'element-plus/theme-chalk/el-select-v2.css'
import zhLocale from 'element-ui/lib/locale/lang/zh-CN'
import qs from 'qs'
import axios from 'axios'
import store from './store'
// import { instance } from './request/http'
import './permission'
import './styles/index.scss' // global css
import 'animate.css'
import '../src/assets/font/myFont.css'

import 'moment/locale/zh-cn'
// import echarts from 'echarts'
import i18n from './lang/index'
import directives from '@/utils/directives.js'
import emoji from '@/utils/emoji.js'
import { message } from '@/utils/resetMessage'
import VueSocketIO from 'vue-socket.io'
import SocketIO from 'socket.io-client'
import './icons' // icon
// import { getSessionId } from '@/utils/auth'
import global from '@/global'
import router from './router'
import tooltip from '@/components/tooltip'
import collapseTransition from '@/utils/transition'
import armRead from '@/utils/arm-read.js'
import armWrite from '@/utils/arm-write.js'
import armCheck from '@/utils/arm-check.js'
import getPageTitle from '@/utils/get-page-title'
// 设置页面标题
document.title = getPageTitle()
import uploader from 'vue-simple-uploader'
import rules from "@/utils/rules.js"
Vue.use(uploader)

Vue.use(armCheck)
Vue.use(armRead)
Vue.use(armWrite)

Vue.use(directives)
Vue.directive('emoji', emoji)
// Vue.use(VueSocketio, 'http://127.0.0.1:443/chat')

axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded'
axios.defaults.timeout = 600 * 1000
axios.defaults.baseURL = global.BASE_URL
const socketOptions = {
  autoConnect: false
  // path: '/chat'
  // extraHeaders: { 'session_id': getSessionId() }
}

Vue.use(new VueSocketIO({
  // debug: true,
  debug: false,
  connection: SocketIO(global.BASE_URL + '/chat', socketOptions),
  // extraHeaders: { 'Access-Control-Allow-Origin': '*' },
  // vuex: {
  //   store,
  //   actionPrefix: 'SOCKET_',
  //   mutationPrefix: 'SOCKET_'
  // },
  options: { path: '/chat' } // Optional options
}, {
  cors: {
    origin: '*'
  }
}))

const echarts = require('echarts') // 按需引入部分组件
Vue.component('tooltip', tooltip)
Vue.component('collapseTransition', collapseTransition)

Vue.use(ElementUI, {
  zhLocale,
  i18n: (key, value) => i18n.t(key, value)
})

Vue.use(ElementUI)
Vue.config.productionTip = false
Vue.prototype.$axios = axios
// Vue.prototype.$axios_url = instance
Vue.prototype.$qs = qs
Vue.prototype.$echarts = echarts
Vue.prototype.$messages = message

Vue.prototype.$rules = rules
Vue.use(echarts)
// axios.defaults.baseURL = 'http://172.18.16.169:443/'

/* eslint-disable no-new */
var vue = new Vue({
  el: '#app',
  router,
  store,
  i18n,
  components: { App },
  template: '<App/>'
})

export default vue
